package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * io流实现文件的复制
 */
public class Demo03 {
    public static void main(String[] args) throws IOException {
        long startTime = System.currentTimeMillis();
        //1.创建输入输出流
        FileInputStream fis = new FileInputStream("E:\\aaa.txt");
        FileOutputStream fos = new FileOutputStream("E:\\b.png");
        //2.连接流
        int ch = 0;
        while ((ch = fis.read()) != -1) {
//   错误写法         fos.write(fis.read());
            fos.write(ch);
        }
        //关闭流
        fis.close();
        fos.close();
        long endTime = System.currentTimeMillis();
        System.out.println("文件复制:" + (endTime-startTime) + "ms");
    }
}
